package tedu.study.day07_2;

import java.util.Scanner;

public class CalAirPrice {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入机票价格：");
        double price = scan.nextDouble();
        System.out.println("请输入月份：");
        int month = scan.nextInt();
        System.out.println("请输入(只输入数字编号即可)：1头等舱 2商务舱 3经济舱");
        int type = scan.nextInt();

        if(checkValue(price,month,type)){
            double finalPrice = calAirPricce(price,month,type);
            System.out.println("最终机票价格是："+finalPrice);
        }else{
            System.out.println("数据错误");
        }
    }

    public static boolean checkValue(double price,int month,int type){
        return price>0.0 && month>=1 && month<=12 && type>=1 && type<=3;
    }

    public static double calAirPricce(double price,int month,int type){
        double finalPrice = 0.0;
        if(month>=5 && month<=10){
            switch (type){
                case 1:finalPrice = price*0.9;break;
                case 2:finalPrice = price*0.85;break;
                case 3:finalPrice = price*0.8;
            }
        }else{
            switch (type){
                case 1:finalPrice = price*0.7;break;
                case 2:finalPrice = price*0.65;break;
                case 3:finalPrice = price*0.6;
            }
        }
        return finalPrice;
    }
}
